'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 公会商店商品
 * @author sundbcn@gmail.com (sun debing)
 */

var mongoose = require('mongoose');
var _ = require('lodash');
var dataApi = require('../../libs/dataApi');

///////////////////////////////////////////////////////////
/**
 * 公会商店商品
 * @type {mongoose}
 */
var unionItemSchema = new mongoose.Schema({
    // 道具类型
    property_id: {
        type: Number,
        required: true
    },

    // 购买次数
    buy_times: {
        type: Number,
        default: 0
    }
});

/**
 * 获取兑换次数
 * @return {[type]} [description]
 */
unionItemSchema.methods.getBuyTimes = function () {
    return this.buy_times;
};

/**
 * 增加兑换次数
 * @return {[type]} [description]
 */
unionItemSchema.methods.addBuyTimes = function () {
    this.buy_times++;
};

/**
 * 获取购买的商品类型
 * @return {[type]} [description]
 */
unionItemSchema.methods.getPropertyId = function () {
    return this.property_id;
};

if (!unionItemSchema.options.toJSON) {
    unionItemSchema.options.toJSON = {};
}
/* jshint unused:false */
unionItemSchema.options.toJSON.transform = function (doc, ret) {
    delete ret._id;
    delete ret.__v;
};

module.exports = unionItemSchema;
